package com.joolun.mall.config;

import com.lop.open.api.sdk.DefaultDomainApiClient;
import com.lop.open.api.sdk.plugin.LopPlugin;
import com.lop.open.api.sdk.plugin.factory.OAuth2PluginFactory;
import lombok.SneakyThrows;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

/**
 * @author quyang
 * @description
 * @date 2022/1/2
 */
@Configuration
@Component("logisticsConfiguration")
public class LogisticsConfiguration {

    @Value("${logistics.jd.serviceUrl}")
    private String serviceUrl;

    @Bean(name = "lopPlugin")
    @SneakyThrows
    public LopPlugin InitJD(){
        return OAuth2PluginFactory.produceLopPlugin(
                serviceUrl,
                "cac871cc6aad468e8cc293087ba1eddf",
                "8957a4e3287245d09b257fe415e497ae",
                "04de4581dbae40d6a0531c246f577682"
        );
    }

    @Bean(name = "defaultDomainApiClient")
    public DefaultDomainApiClient InitJDClient(){
        return new DefaultDomainApiClient(serviceUrl);
    }
}
